home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / ixemlsrc.lha / ixemul / network / page.h < prev    next >
C/C++ Source or Header  |  1995-12-23  |  4KB  |  98 lines

  1. #ifndef _PAGE_H_
  2. #define _PAGE_H_
  3.  
  4. /*-
  5.  * Copyright (c) 1990 The Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * This code is derived from software contributed to Berkeley by
  9.  * Margo Seltzer.
  10.  *
  11.  * Redistribution and use in source and binary forms, with or without
  12.  * modification, are permitted provided that the following conditions
  13.  * are met:
  14.  * 1. Redistributions of source code must retain the above copyright
  15.  *    notice, this list of conditions and the following disclaimer.
  16.  * 2. Redistributions in binary form must reproduce the above copyright
  17.  *    notice, this list of conditions and the following disclaimer in the
  18.  *    documentation and/or other materials provided with the distribution.
  19.  * 3. All advertising materials mentioning features or use of this software
  20.  *    must display the following acknowledgement:
  21.  *    This product includes software developed by the University of
  22.  *    California, Berkeley and its contributors.
  23.  * 4. Neither the name of the University nor the names of its contributors
  24.  *    may be used to endorse or promote products derived from this software
  25.  *    without specific prior written permission.
  26.  *
  27.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  28.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  31.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  35.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  36.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  37.  * SUCH DAMAGE.
  38.  *
  39.  *    @(#)page.h    5.1 (Berkeley) 2/12/91
  40.  */
  41.  
  42. /*
  43.     Definitions for hashing page file format.
  44. */
  45. extern    HTAB    *hashp;
  46. /*
  47.  * routines dealing with a data page
  48.  *
  49.  * page format:
  50.  *    +------------------------------+
  51.  * p    | n | keyoff | datoff | keyoff |
  52.  *     +------------+--------+--------+
  53.  *    | datoff | free  |  ptr  | --> |
  54.  *    +--------+---------------------+
  55.  *    |     F R E E A R E A       |
  56.  *    +--------------+---------------+
  57.  *    |  <---- - - - | data          |
  58.  *    +--------+-----+----+----------+
  59.  *    |  key   | data     | key      |
  60.  *    +--------+----------+----------+
  61.  *
  62.  * Pointer to the free space is always:  p[p[0] + 2]
  63.  * Amount of free space on the page is:  p[p[0] + 1]
  64.  */
  65.  
  66. /*
  67.     How many bytes required for this pair?
  68.     2 shorts in the table at the top of the page +
  69.     room for the key and room for the data
  70.  
  71.     We prohibit entering a pair on a page unless there is also
  72.     room to append an overflow page. The reason for this it that
  73.     you can get in a situation where a single key/data pair fits
  74.     on a page, but you can't append an overflow page and later
  75.     you'd have to split the key/data and handle like a big pair.
  76.     You might as well do this up front.
  77.  
  78. */
  79. #define    PAIRSIZE(K,D)    (2*sizeof(u_short) + K->size + D->size)
  80. #define BIGOVERHEAD    (4*sizeof(u_short))
  81. #define KEYSIZE(K)    (4*sizeof(u_short) + K->size);
  82. #define OVFLSIZE    (2*sizeof(u_short))
  83. #define FREESPACE(P)    (P[P[0]+1])
  84. #define    OFFSET(P)    (P[P[0]+2])
  85. #define PAIRFITS(P,K,D)    ((P[1] >= REAL_KEY) && \
  86.              (PAIRSIZE(K,D) + OVFLSIZE) <= FREESPACE(P))
  87. #define PAGE_META(N)    ((N+3) * sizeof(u_short))
  88.  
  89. typedef struct {
  90.     BUFHEAD    *newp;
  91.     BUFHEAD    *oldp;
  92.     BUFHEAD    *nextp;
  93.     u_short    next_addr;
  94. } SPLIT_RETURN;
  95.  
  96.  
  97. #endif
  98.